# Copyright (c) 2006, 2007 Julio M. Merino Vidal
# Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
# Copyright (c) 2009 Boris Schaeling
# Copyright (c) 2010 Felipe Tanus, Boris Schaeling
# Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
# Copyright (c) 2016 Klemens D. Morgenstern
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)


import os ;

if [ os.name ] = NT
{
  lib ws2_32 ;
  lib shell32 ;
  lib Advapi32 ;
  lib Ntdll ;
}

project : requirements
  <define>BOOST_ASIO_NO_DEPRECATED
  <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
  <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
  <toolset>msvc:<cxxflags>/bigobj
  <target-os>windows:<define>WIN32_LEAN_AND_MEAN
  <target-os>linux:<linkflags>-lpthread
  <os>NT,<toolset>cw:<library>ws2_32
  <os>NT,<toolset>gcc:<library>ws2_32
;



import testing ;


alias program_options  : /boost//program_options : <link>static ;
alias filesystem       : /boost//filesystem      ;
alias iostreams        : /boost//iostreams       ;
alias system           : /boost//system          ;
alias thread           : /boost//thread          ;
alias coroutine        : /boost//coroutine       : <link>static ;

lib multi_ref : multi_ref1.cpp multi_ref2.cpp system : <target-os>windows:<source>shell32 ;

exe sparring_partner : sparring_partner.cpp program_options system filesystem iostreams :
    <warnings>off <target-os>windows:<source>shell32 <target-os>windows:<source>Ntdll
    ;

exe exit_argc : exit_argc.cpp :
    <warnings>off <target-os>windows:<source>shell32
    ;

exe sub_launch : sub_launcher.cpp program_options iostreams system filesystem : <warnings>off <target-os>windows:<source>shell32 ;

rule test-options ( name )
{
    if "--boost-process-report-ci" in [ modules.peek : ARGV ]
    {
        return --log_sink=log_$(name).xml --log_format=XML --log_level=error --report_sink=report_$(name).xml --report_format=XML --report_level=detailed -- ;
    }
    else
    {
        return --log_level=error --report_level=detailed -- ;
    }

}


test-suite bare :
    [ run environment.cpp system filesystem : [ test-options environment ] ]
    [ run async_pipe.cpp  system filesystem : [ test-options async_pipe ] ]
    [ run pipe.cpp        system filesystem : [ test-options pipe ] ]
    [ compile no_ansi_apps.cpp ]
    [ compile-fail spawn_fail.cpp        ]
    [ compile-fail async_system_fail.cpp ]
    [ compile asio_no_deprecated.cpp ]
    ;

test-suite with-valgrind :
    [ run async.cpp       system thread filesystem            : [ test-options async ] : sparring_partner ]
    [ run async_fut.cpp   system thread filesystem            : [ test-options async_fut ] : sparring_partner ]
    [ run args_handling.cpp  system thread filesystem         : [ test-options args_handling ] : exit_argc ]
    [ run args_cmd.cpp    system filesystem                   : [ test-options args_cmd ] : sparring_partner ]
    [ run wargs_cmd.cpp    system filesystem                  : [ test-options wargs_cmd ] : sparring_partner ]
    [ run bind_stderr.cpp     filesystem                      : [ test-options bind_stderr ] : sparring_partner ]
    [ run bind_stdin.cpp     system filesystem                : [ test-options bind_stdin ] : sparring_partner ]
    [ run bind_stdin_stdout.cpp     system filesystem         : [ test-options bind_stdin_stdout ] : sparring_partner ]
    [ run bind_stdout.cpp     system filesystem               : [ test-options bind_stdout ] : sparring_partner ]
    [ run bind_stdout_stderr.cpp     system filesystem        : [ test-options bind_stdout_stderr ] : sparring_partner ]
    [ run pipe_fwd.cpp         system filesystem              : [ test-options pipe_fwd ] : sparring_partner ]
    [ run cmd_test.cpp         system filesystem              : [ test-options cmd_test ] : sparring_partner ]
    [ run close_stderr.cpp     system filesystem              : [ test-options close_stderr ] : sparring_partner ]
    [ run close_stdin.cpp      system filesystem              : [ test-options close_stdin ] : sparring_partner ]
    [ run close_stdout.cpp     system filesystem              : [ test-options close_stdout ] : sparring_partner ]
    [ run error.cpp            system filesystem              : [ test-options error ] : sparring_partner ]
    [ run exit_code.cpp program_options system filesystem     : [ test-options exit_code ] : sparring_partner ]
    [ run extensions.cpp system filesystem                    : [ test-options extensions ] : sparring_partner ]
    [ run env.cpp     program_options system filesystem       : [ test-options env ] : sparring_partner ]
    [ run group.cpp     system thread filesystem              : [ test-options group ] : sub_launch ]
    [ run group.cpp          system thread filesystem         : [ test-options group ] : sub_launch : <build>no <target-os>windows:<build>yes <define>BOOST_USE_WINDOWS_H=1 : group-windows-h ]
    [ run group_wait.cpp     system thread filesystem         : [ test-options group_wait ] : sparring_partner ]
	[ run limit_fd.cpp     program_options system filesystem  : [ test-options limit_fd ] : sparring_partner ]
    [ run run_exe.cpp filesystem                              : : sparring_partner ]
    [ run run_exe_path.cpp filesystem                         : [ test-options run_exe_path ] : sparring_partner ]
    [ run search_path.cpp filesystem system                   : [ test-options search_path ] : : <target-os>windows:<source>shell32 ]
    [ run shell.cpp filesystem system                         : [ test-options shell ] : sparring_partner ]
    [ run shell_path.cpp  filesystem system                   : [ test-options shell_path ] ]
    [ run system_test1.cpp filesystem system                  : [ test-options system_test1 ] : sparring_partner ]
    [ run system_test2.cpp filesystem system                  : [ test-options system_test2 ] : sparring_partner ]
    [ run spawn.cpp filesystem system                         : [ test-options spawn ] : sparring_partner ]
    [ run start_dir.cpp   filesystem system                   : [ test-options start_dir ] : sparring_partner ]
    [ run terminate.cpp system filesystem                     : [ test-options terminate ] : sparring_partner ]
    [ run throw_on_error.cpp system filesystem                : [ test-options throw_on_error ] : sparring_partner ]
    [ run wait.cpp system filesystem                          : [ test-options wait ] : sparring_partner ]
    [ run wait_for.cpp system filesystem                      : [ test-options wait_for ] : sparring_partner ]
    [ run on_exit.cpp  system filesystem                      : [ test-options on_exit ] : sparring_partner ]
    [ run on_exit2.cpp system filesystem                      : [ test-options on_exit2 ] : sparring_partner ]
    [ run on_exit3.cpp system filesystem                      : [ test-options on_exit3 ] : sparring_partner ]
    [ run posix_specific.cpp     system filesystem            : [ test-options posix_specific ] : sparring_partner : <build>no <target-os>linux:<build>yes   ]
    [ run windows_specific.cpp filesystem system              : [ test-options windows_specific ] : sparring_partner : <build>no <target-os>windows:<build>yes   ]
   : <dependency>bare ;

test-suite without-valgrind :
    [ run async_system_future.cpp filesystem system coroutine           : [ test-options async_system_future ] : sparring_partner : <link>static <toolset>msvc:<cxxflags>/bigobj ]
    [ run async_system_stackful.cpp filesystem system coroutine         : [ test-options async_system_stackful ] : sparring_partner : <link>static <toolset>msvc:<cxxflags>/bigobj ]
    [ run async_system_stackful_error.cpp filesystem system coroutine   : [ test-options async_system_stackful_error ] : sparring_partner : <link>static <toolset>msvc:<cxxflags>/bigobj ]
    [ run async_system_stackful_except.cpp filesystem system coroutine  : [ test-options async_system_stackful_except ] : sparring_partner : <link>static <toolset>msvc:<cxxflags>/bigobj ]
    [ run async_system_stackless.cpp filesystem system coroutine        : [ test-options async_system_stackless ] : sparring_partner : <link>static <toolset>msvc:<cxxflags>/bigobj ]
    [ run vfork.cpp     system filesystem                               : [ test-options vfork ] : sparring_partner : <build>no <target-os>linux:<build>yes ]
    ;


